package com.ishell.generate;

import com.ishell.generate.bean.DataTypeEnum;
import com.ishell.generate.util.ConvertUtil;
import org.apache.commons.lang.StringUtils;

import java.util.Map;

/**
 * 作者: crazier.huang
 * 项目: generate
 * 日期: 2018/6/9 星期六
 * 说明: 属相相关说明
 */
public class ColumnDesc {

    private String tableName;

    private String columnName;

    private String name;

    private String comment;

    private String dataType;

    private Class clazz;

    private String columnKey;

    private String annotation;

    private String getMethod;

    private String setMethod;

    private String priDataType;


    public ColumnDesc() {
    }
    public ColumnDesc(Map<String,Object> rmap) {
        this.tableName = (String) rmap.get("TABLE_NAME");
        this.columnName = (String) rmap.get("COLUMN_NAME");
        this.name = ConvertUtil.camel(this.columnName.toLowerCase());
        this.comment = (String) rmap.get("COLUMN_COMMENT");
        this.dataType = (String) rmap.get("DATA_TYPE");
        this.columnKey = (String) rmap.get("COLUMN_KEY");
        this.clazz = DataTypeEnum.parseByType(this.dataType);
        this.annotation = StringUtils.equals("PRI",columnKey) ? "@Id" : "@Column" ;
        this.getMethod = "get"+ConvertUtil.upperCase(this.name);
        this.setMethod = "set"+ConvertUtil.upperCase(this.name);
    }

    public String getTableName() {
        return tableName;
    }

    public void setTableName(String tableName) {
        this.tableName = tableName;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getComment() {
        return comment;
    }

    public void setComment(String comment) {
        this.comment = comment;
    }

    public String getDataType() {
        return dataType;
    }

    public void setDataType(String dataType) {
        this.dataType = dataType;
    }

    public Class getClazz() {
        return clazz;
    }

    public String getColumnKey() {
        return columnKey;
    }

    public String getAnnotation() {
        return annotation;
    }

    public String getColumnName() {
        return columnName;
    }

    public String getGetMethod() {
        return getMethod;
    }

    public String getSetMethod() {
        return setMethod;
    }
}
